#ifndef _UTILEX_FILE_HPP_
#define _UTILEX_FILE_HPP_

#include <crt_util.h>

#ifdef __cplusplus


static_inline basic_tstring GetExePathString() {

	basic_tchar szPath[MAX_PATH + 1] = { 0x00 };
	GetExecutePath(INSNULL, szPath, MAX_PATH);
	//UINT pathlen = tstring_strlen(szPath);
	basic_tstring strPath(szPath);
	return strPath;
}

static_inline BYTE* ReadFileMem(const basic_tstring &src, unsigned long& len) {

	_fd_t	hFile	= INVALID_HANDLE_VALUE;
	size_t read		= 0;
	BYTE* data	= NULL;
	hFile = _file_open(src.c_str(), O_RDWR, 0644);
	rc_assert(hFile != INVALID_HANDLE_VALUE, NULL);

	size_t ulFileLen = _file_fsize(hFile) & UINT32_MAX;
	if (ulFileLen == 0)
		goto end;

	read = ulFileLen & UINT32_MAX;

	data = ALLOC_NEW BYTE[ulFileLen + 1]();

	if (data == NULL)
		goto end;

	len = _file_read(hFile, data, read);
end:
	_file_close(hFile);
	return data;
}


#endif





#endif
